import { defHttp } from './../../utils/request/index'
import type { LoginByPassword, TokenResult, User } from '@/types/user'

enum Api {
  LoginByPassword = '/auth/login',
  GetUserRouter = 'system/user/routers',
  GetUserProfile = '/user/profile',
  UserList = 'system/user/list',
  ChangeStatus = 'system/user/status',
  newUser = 'system/user/add',
  editUser = 'system/user/edit',
  getUserInfo = 'system/user/',
  deleteUser = 'system/user/'
}

/**
 *  密码登陆
 */
export const loginByPasswordApi = (params: LoginByPassword) => defHttp.post<TokenResult>(Api.LoginByPassword, params)

/**
 * 获取当前用户信息
 */
export const getProfileApi = () => defHttp.get<User>(Api.GetUserProfile)

/**
 * 更改用户状态
 * @param userId
 */
export const changeUserStatusApi = (userId: number) => defHttp.get(Api.ChangeStatus, { userId: userId })

/**
 * 获取用户信息
 * @param userId 用户Id
 */
export const deleteUserApi = (userId: number) => defHttp.delete(Api.getUserInfo + userId)
